package com.ruoyi.web.controller.demo.controller;

import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpRequest;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.domain.SysSdt;
import com.ruoyi.system.service.SysSdtService;
import com.ruoyi.system.service.impl.ByteToMultipartFile;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.CookieStore;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.cookie.Cookie;
import org.apache.http.entity.StringEntity;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.impl.client.BasicCookieStore;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.htmlcleaner.CleanerProperties;
import org.htmlcleaner.DomSerializer;
import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @Author hnb
 * @Date 2024/12/26
 * @Description 获取山东通数据
 **/

@RestController
@RequestMapping("/sysSdt")
public class Getjiaotong extends BaseController {

    @Autowired
    private SysSdtService sysSdtService;
    private static final Logger log = LoggerFactory.getLogger(DechenFormContentController.class);
    String cookie = null;

    @Log(title = "获取山东通数据", businessType = BusinessType.OTHER)
    @GetMapping("/getData")
    public AjaxResult getData()throws Exception{
        String url = "http://10.154.136.200/oa/NOTICE/noticeManageList.aspx?pstrid=BTZGG";
        String url1 = "http://10.154.136.200/oa/NOTICE/noticeShow.aspx?strid=noticeShow0.9446674922520277&pstrid=tab_NBJL_TZGL&id=";
        List<String> lists = crawlList(url);

        SysSdtService sysSdtServiceBean= SpringUtils.getBean(SysSdtService.class);
        List<SysSdt> sysSdts = sysSdtServiceBean.selectList(new SysSdt());
        List<String> collect = sysSdts.stream().map(SysSdt::getId).collect(Collectors.toList());
        for (String id : lists) {
           if(!collect.contains(id)){
                crawlDetail(url1,id);
            }
        }
        return AjaxResult.success();
    }

    /**
     * 获取列表
     * @param url
     * @return
     */
    public  List<String> crawlList(String url) throws UnsupportedEncodingException, XPathExpressionException, ParserConfigurationException {
        // 创建HttpClient实例
        CloseableHttpClient httpClient = HttpClients.createDefault();
        // 创建HttpPost实例，设置URL
        HttpPost httpPost = new HttpPost(url);
        // 创建form-data参数
        List<NameValuePair> formParams = new ArrayList<>();
        formParams.add(new BasicNameValuePair("Scriptmanager1", "UpdatePanel1|Menu1"));
        formParams.add(new BasicNameValuePair("ddlDateCondition", "none"));
        formParams.add(new BasicNameValuePair("hfType", "WD"));
        formParams.add(new BasicNameValuePair("hfDiyApprovePage", "NewWorkApproveDIYNew.aspx"));
        formParams.add(new BasicNameValuePair("hfSolidApprovePage", "NewWorkApproveNew.aspx"));
        formParams.add(new BasicNameValuePair("hfPstrid", "BTZGG"));
        formParams.add(new BasicNameValuePair("DataPage1$txtPageSize", "100"));
        formParams.add(new BasicNameValuePair("DataPage1$hfCurrentPageIndex", "1"));
        formParams.add(new BasicNameValuePair("__EVENTTARGET", "Menu1"));
        formParams.add(new BasicNameValuePair("__EVENTARGUMENT", "WD"));
//        String viewstate = getVIEWSTATE();
        formParams.add(new BasicNameValuePair("__VIEWSTATE","kPT8w6GlpY/NHrxFRRj7z4bXMbBWb6oTtR6Elh2POD7x8aP7WIiVJvTW8fO5iPSY87GZ6y9r0IbbgCqWi8XXBAyIRY8J0Q6vYwYuujFyv6c8w7O2wrK8E6o2cyK97sT+TqJlYyDanAKoMebGa751vaKoyVm7kLy8xtCI9YiwjNYrjcfqkKnGb5MN2Pin2NF8Uh1XzGuTsaMRWAbrygHK7A0fqfqYeo3DTtDQta50SUODWtgZ6irXjusw9V4bmfBG4QALPFVd7V9f34XbV9nEa7GUFJfMMXi4zQIeUKokqZlRrr0xy6DfWqg6+xwmuaUoVhy5zYnyfmyjIwayA+nXqR5QvY5AcNUt51HX+Kd1nSf2O1KteIijVS2+aTxxNjSMV16dKdcOnZFNpNN+EDZ7Wdh45hrX5jOgOZ5ZUSYQ5oFqAYkeSpNBjgtRloMArI/UX3aepRb0gG5fuY78wbgEoSdFU/b9XgeWvk5KPeLFDk8xPmpOIraDbA8oSpjf0fcDdiQdMf3A8JCnC3nopp5b8lqCXcrszICCP3hWMGvR9RUkB5kjFUTZ8kTU7edgYEwXw52zCYSvKhv4DWA1zkz1wA8R1jRnUFptSnYEJr50iDjhEngyQpqCIKtvgR2TEQKlGRCdUR+wnowhIjcB42gQ4Zw8CYAb6x7TEQr55hJMXKA9Y1fn89hGNbwUOwRW8X20iPPqyw4IAIYLLrxiCxX7dY3bGxBqG3MwdWMDwP9i+JzB4Jb3Dn8Ibwx2bPEY6IifJG/nxg=="));
        formParams.add(new BasicNameValuePair("__VIEWSTATEGENERATOR", "F9829FDA"));
        formParams.add(new BasicNameValuePair("__VIEWSTATEENCRYPTED", ""));
        formParams.add(new BasicNameValuePair("__ASYNCPOST", "ture"));

        // 设置form-data到请求
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, "UTF-8");
        httpPost.setEntity(entity);
        // 设置请求头部的信息
        httpPost.setHeader("Content-type", "application/x-www-form-urlencoded; charset=UTF-8");
        httpPost.setHeader("X-Microsoftajax", "Delta=true");
        httpPost.setHeader("X-Requested-With", "XMLHttpRequest");
        httpPost.setHeader("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36");
        httpPost.setHeader("Cookie", cookie);
        try {
            // 执行请求
            HttpResponse response = httpClient.execute(httpPost);
            // 获取响应的内容
            String responseBody = EntityUtils.toString(response.getEntity());
            //1|#||4|25|pageRedirect||%2foa%2fSessionError.aspx|
            if(responseBody.contains("pageRedirect")){
                try {
                    Map<String, String> map = getCookie();
                    cookie = "ASP.NET_SessionId="+map.get("ASP.NET_SessionId");
                    httpPost.setHeader("Cookie", cookie);
                    // 创建HttpClient实例
                    CloseableHttpClient httpClient1 = HttpClients.createDefault();
                    HttpResponse response1 = httpClient1.execute(httpPost);
                    // 获取响应的内容
                    responseBody = EntityUtils.toString(response1.getEntity());
                }catch (Exception e){
                    log.error("获取列表页面内容失败");
                }
            }
            List<String> list = new ArrayList<>();
            String html = responseBody;
            // 解析 HTML 页面内容
            HtmlCleaner hc = new HtmlCleaner();
            TagNode tn = hc.clean(html);
            Document document = new DomSerializer(new CleanerProperties()).createDOM(tn);

            // 匹配获取需要的数据
            XPath xPath = XPathFactory.newInstance().newXPath();
            String exp = "//tr[@class=\"GvRow\"]/@onclick";
            NodeList nodes = (NodeList) xPath.evaluate(exp, document, XPathConstants.NODESET);

            for (int length = nodes.getLength(), i = 0; i < length; i++) {
                Node item = nodes.item(i);
                String textContent = item.getTextContent();
                String id = textContent.split("J_OnFoucsNoticeClick\\(this,'#DEE6E9','")[1].split("','")[0];
                list.add(id);
            }
            System.out.println("获取山东通列表："+list);
            return list;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        System.out.println("获取山东通列表失败！");
        return null;
    }

    /**
     * 获取详情页面的内容
     * @param url
     * @param id
     * @throws UnsupportedEncodingException
     * @throws ParserConfigurationException
     * @throws XPathExpressionException
     */
    public void crawlDetail(String url,String id) throws UnsupportedEncodingException, ParserConfigurationException, XPathExpressionException {
        // 创建HttpClient实例
        CloseableHttpClient httpClient = HttpClients.createDefault();
        // 创建HttpPost实例，设置URL
        HttpPost httpPost = new HttpPost(url+id);
        // 设置表单参数
        // 这里以键值对的形式提供参数，可以根据实际需要添加更多的参数
        String param = "Scriptmanager1=UpdatePanel1%7CMenu1&txtTitle=&txtDate1=&txtDate2=&txtUserName=&ddlDateCondition=none&hfID=&hfType=YD&hfContent=&hfMenuID=8208272&hfMenuName=%E9%80%9A%E7%9F%A5&hfDiyApprovePage=NewWorkApproveDIYNew.aspx&hfSolidApprovePage=NewWorkApproveNew.aspx&hfPstrid=BTZGG&DataPage1%24txtPageSize=11&DataPage1%24txtbNum=1&DataPage1%24hfCurrentPageIndex=1&__EVENTTARGET=Menu1&__EVENTARGUMENT=YD&__VIEWSTATE=3Mqglr2IVgx%2BZZAkqOfpJI7BEDIAZ0LcbZ6UjUMOLp4Tk%2B75IHg7Xi1jv1jxmdqHfStqYLul9V%2FFi6VkH7cm2Sl221oznyFirkdhtssg%2BkfknEgS6E%2FZMfFMZkc0NHU4DRWuUWr5kRLZNYRv7p7wnPbx9bz6Zg6ADSz9EnTKlcppzSrW4%2FCXNtUObxpdi123JzPuk1bj7BwM4iM4bL5k3ESQzp%2FaUF7kAacRkLlb4IdNs90IDsX7DKvpA7jZtCApi3iaiaQQMguwUopVPzb44uT%2Ft9IL01%2Bo6DKkjWNuRaBjMZKnzH1Su3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BcuHN20UlypY1z3ulw8h8tWsTKV9ElG0Hp0fQxspUWNFp3rnfaLsmGZy8Lv5jWWfG8%2FeiYPzwpBV%2F9QaQNao5zpZfulYO4lp4D%2FTMt6SUDJIH1Iv8y1c6aVAzpRmlUS3bj%2F7uQfPqQRw7eh5tXf5thFb5mUsO7ejRdHeDOBZ14Q0E%2FdbKj9h9DpOvjlHQdNp8o816pf6ZXpLc73vZL7h6E4RH0j8yOZudzOmxd1cOW45yWHSLsmsYx%2FUdF5PBORQmh1VcakytDTX9hlxjAEMIV%2FpdXvriPjF7Id2s9Lhjqhc9KzHwTtok2qYSHuDzTPElQ554uQL%2BRZYjb1JRa3aAuOTdagk5goG2mxxizjnYaXQWXu6V8oRauQtGrUhBJWXjkLbfGSKIm%2Feg4Z7CEfwhPUTlrKwOY9XFZdbz1eoDmPlq6ql6p4hBrqJi2W05SPI4cEMxKQRBZb9N49tdfj4R4C%2B6mBwhsnzlsnBe7y%2BP%2B3bgdeOoPFppg9WBscJiKYvUls%2BiumxQVV1xyi9UfBsqSMZgPSMCbdY8epadEcU9milRX4ss4MgpeZB8t91wzCOF7S7YQ1QxoZ58A8Ws8YAiin6eVclHTxRNml3QGuL5Q8aZ9xzYJ7oO5LdejA7PuaziN9S5y%2Fpwq%2Fokn4zB3PisQ2FprIbOt6LFV1ZArpaNcCMEZUUyY%3D&__VIEWSTATEGENERATOR=F9829FDA&__VIEWSTATEENCRYPTED=&__ASYNCPOST=true&";
        StringEntity requestEntity = new StringEntity(param);
        httpPost.setEntity(requestEntity);
        // 设置请求头部的信息
        httpPost.setHeader("Content-type", "application/json");
        httpPost.setHeader("Cookie", cookie);

        try {
            // 执行请求
            HttpResponse response = httpClient.execute(httpPost);
            // 获取响应的内容
            String responseBody = EntityUtils.toString(response.getEntity());
            if(responseBody.contains("pageRedirect")) {
                try {
                    Map<String, String> map = getCookie();
                    cookie = "ASP.NET_SessionId=" + map.get("ASP.NET_SessionId");
                    httpPost.setHeader("Cookie", cookie);
                    // 创建HttpClient实例
                    CloseableHttpClient httpClient1 = HttpClients.createDefault();
                    HttpResponse response1 = httpClient1.execute(httpPost);
                    // 获取响应的内容
                    responseBody = EntityUtils.toString(response1.getEntity());
                } catch (Exception e) {
                    log.error("获取详情页面内容失败");
                }
            }
            // 解析 HTML 页面内容
            HtmlCleaner hc = new HtmlCleaner();
            TagNode tn = hc.clean(responseBody);
            Document document = new DomSerializer(new CleanerProperties()).createDOM(tn);

            // 匹配获取需要的数据
            XPath xPath = XPathFactory.newInstance().newXPath();
            String lblTitle = ((NodeList) xPath.evaluate("//span[@id=\"lblTitle\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String textlblDept = ((NodeList) xPath.evaluate("//span[@id=\"lblDept\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String textlblUsername = ((NodeList) xPath.evaluate("//span[@id=\"lblUsername\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String textlblPublishdate = ((NodeList) xPath.evaluate("//span[@id=\"lblPublishdate\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String textlblImportantlevel = ((NodeList) xPath.evaluate("//span[@id=\"lblImportantlevel\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String textlblPublic = ((NodeList) xPath.evaluate("//span[@id=\"lblPublic\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            String texteditor = ((NodeList) xPath.evaluate("//textarea[@id=\"editor\"]", document, XPathConstants.NODESET)).item(0).getTextContent();
            //保存附件
            Map<String, String> extracted = extracted(xPath, document);
            String file = extracted.get("file");
            String filePath = extracted.get("filePath");
            SysSdt sysSdt = new SysSdt() {{
                setId(id);
                setLblTitle(lblTitle);
                setLblDept(textlblDept);
                setLblUsername(textlblUsername);
                setLblPublishdate(DateUtils.parseDate(textlblPublishdate));
                setLblImportantlevel(textlblImportantlevel);
                setLblPublic(textlblPublic);
                setEditor(texteditor);
                setFile(file);
                setFilePath(filePath);
                setCreateTime(DateUtil.date());
            }};
            SysSdtService sysSdtServiceBean= SpringUtils.getBean(SysSdtService.class);
            sysSdtServiceBean.insert(sysSdt);

        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    /**
     * 获取 附件信息
     * @param xPath
     * @param document
     * @return
     * @throws XPathExpressionException
     * @throws IOException
     */
    private static Map<String,String> extracted(XPath xPath, Document document) throws XPathExpressionException, IOException {
        String expression = "//a[contains(@onclick, 'DownLoadFile')]";
        String file = "";
        String filePath = "";
        NodeList nodes1 = (NodeList) xPath.evaluate(expression, document, XPathConstants.NODESET);
        List<Map<String, String>> list = new ArrayList<>();
        for (int i = 0; i < nodes1.getLength(); i++) {
            Node node = nodes1.item(i);
            if (node instanceof Element) {
                Element element = (Element) node;
                // 获取onclick属性的值
                String onclickValue = element.getAttribute("onclick");
                String ids = onclickValue.split("DownLoadFile\\( '")[1].split("','")[0];
                String name = onclickValue.split("DownLoadFile\\( '")[1].split("','")[1].split("', '")[0];
                String attachment = onclickValue.split("DownLoadFile\\( '")[1].split("','")[1].split("', '")[1].split("'\\);")[0];
                HashMap<String, String> hashMap = new HashMap<String, String>() {{
                    put("id", ids);
                    put("name", name);
                    put("attachment", attachment);
                }};
                list.add(hashMap);
                String fileUrl = "http://10.154.136.200/oa/UCTR/FileDownLoad.aspx?NewName="+ids+"&OldName="+ URLEncoder.encode(name)+"&FilePath="+attachment;
                file += fileUrl + ";";
                // 本地资源路径
                String localPath = RuoYiConfig.getProfile();
                String targetPath = localPath+name;
                String fileName = downloadFileWithHttpClient(fileUrl,targetPath,name);
                filePath += fileName+";";
            }
        }
        String finalFile = file;
        String finalFilePath = filePath;
        return new HashMap<String, String>(){{
            put("file", finalFile);
            put("filePath", finalFilePath);
        }};
    }
    /**
     * 获取cookie
     * @return
     * @throws IOException
     */
    public static Map<String,String> getCookie() throws IOException {
        // 创建一个Cookie存储对象
        CookieStore cookieStore = new BasicCookieStore();
        // 创建一个支持cookie的HttpClient
        HttpClient client = HttpClients.custom().setDefaultCookieStore(cookieStore).build();
        // 登录表单的URL
        String loginUrl = "http://10.154.136.200/oa/UserLogin.ashx";
        // 创建一个HttpPost对象
        HttpPost post = new HttpPost(loginUrl);
        // 使用MultipartEntityBuilder构建form-data
        MultipartEntityBuilder builder = MultipartEntityBuilder.create();
        String username = "yinguibing";
        String password = "ygb612316";
        String userNameText = Base64.getEncoder().encodeToString((username + DateUtil.format(new Date(), "yyyyMMdd") + ",xh,").getBytes());
        String passWordText = Base64.getEncoder().encodeToString((password + DateUtil.format(new Date(), "yyyyMMdd") + ",xh,").getBytes());
        String code = userNameText +"|"+ passWordText+"||Safari|2560||false|";
        builder.addTextBody("keycode2", code); // 添加文本字段
        // 构建HttpEntity
        HttpEntity multipart = builder.build();
        // 设置请求实体
        post.setEntity(multipart);
        // 执行登录操作
        HttpResponse response = client.execute(post);
        System.out.println("登录结果："+EntityUtils.toString(response.getEntity()));
        // 获取cookie
        List<Cookie> cookies = cookieStore.getCookies();
        Map<String, String> returenMap = new HashMap<>();
        returenMap.put(cookies.get(0).getName(),cookies.get(0).getValue());
        return returenMap;
    }

    /**
     * 使用Apache HttpClient下载文件到本地
     * @param urlStr 文件的网络地址
     * @param targetPath 本地保存的路径及文件名
     * @throws IOException 网络连接或文件I/O异常
     */
    public static String downloadFileWithHttpClient(String urlStr, String targetPath,String name) throws IOException {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet(urlStr);
        String fileName = "";
        HttpResponse response = httpClient.execute(httpGet);
        if (response.getStatusLine().getStatusCode() == 200) {
            byte[] fileBytes = EntityUtils.toByteArray(response.getEntity());
            MultipartFile multipartFile = new ByteToMultipartFile(fileBytes, "file", name, "application/octet-stream");
            // 上传文件路径
            String filePath = RuoYiConfig.getUploadPath();
            // 上传并返回新文件名称
            fileName = FileUploadUtils.upload(filePath, multipartFile);
            EntityUtils.consume(response.getEntity()); // 保证HTTP连接释放
        } else {
            throw new IOException("Failed to download file. HTTP response code: " + response.getStatusLine().getStatusCode());
        }
        httpClient.close();
        return fileName;
    }

    /**
     * @return
     * @throws IOException
     */
    public static Map<String,String> getCookieAA() throws IOException {
        // 创建一个Cookie存储对象
        CookieStore cookieStore = new BasicCookieStore();

        // 创建一个支持cookie的HttpClient
        HttpClient client = HttpClients.custom().setDefaultCookieStore(cookieStore).build();

        // 登录表单的URL
        String loginUrl = "http://10.154.136.200/oa/NOTICE/noticeManageList.aspx?pstrid=BTZGG";

        // 创建一个HttpPost对象
        HttpPost post = new HttpPost(loginUrl);

        // 创建form-data参数
        List<NameValuePair> formParams = new ArrayList<>();
        formParams.add(new BasicNameValuePair("Scriptmanager1", "UpdatePanel1|Menu1"));
        formParams.add(new BasicNameValuePair("txtTitle", null));
        formParams.add(new BasicNameValuePair("txtDate1", null));
        formParams.add(new BasicNameValuePair("txtDate2", null));
        formParams.add(new BasicNameValuePair("txtUserName", null));
        formParams.add(new BasicNameValuePair("ddlDateCondition", "none"));
        formParams.add(new BasicNameValuePair("hfID", null));
        formParams.add(new BasicNameValuePair("hfType", "YF"));
        formParams.add(new BasicNameValuePair("hfContent", null));
        formParams.add(new BasicNameValuePair("hfMenuID", null));
        formParams.add(new BasicNameValuePair("hfMenuName", null));
        formParams.add(new BasicNameValuePair("hfDiyApprovePage", "NewWorkApproveDIYNew.aspx"));
        formParams.add(new BasicNameValuePair("hfSolidApprovePage", "NewWorkApproveNew.aspx"));
        formParams.add(new BasicNameValuePair("hfPstrid", "BTZGG"));
        formParams.add(new BasicNameValuePair("DataPage1$txtPageSize: ", "5"));
        formParams.add(new BasicNameValuePair("DataPage1$txtbNum", "1"));
        formParams.add(new BasicNameValuePair("DataPage1$hfCurrentPageIndex", "1"));
        formParams.add(new BasicNameValuePair("__EVENTTARGET", "Menu1"));
        formParams.add(new BasicNameValuePair("__EVENTARGUMENT", "YF"));
//        formParams.add(new BasicNameValuePair("__VIEWSTATE", "iYA2QI2EFb6holCGs9Nm/LPW//SZXLBhDcOz1anNG9CsMG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0yrYhu/mS1wPyzamUHN9ryekQ1YeDtWdyz2LSWYkkB5b78jt6aRqkHjs2S9C8FNHLWs2CKiGVXkAtKWVzcaK/FY4iqJ7loLJSunwTZZO8pO8pvjzAPncyJw9qW6l/wzk/2ncgsFROLHZE4s5m3TzDcokti6HIfFPj8809dUIRZaWlXSAXFaapUMa1NI0EFHvjW9L4mAyF2NEKiOZR32i/ve+jicfSPuEbznJWgEhjNLhcGeMOA3kxvxB3DmXsVLmen6Xy2VTtn5texoF0RjWiHPW9APkpsEtbaCbvxlKXiwecakmMW6f3ypjiDS6PKn/zJQTl9L11cXso52p0SBCE2gPiso9UHpbnvBle7ryVH3TmO/HCrWMB8CHtSzYj8+laGpOkGXjMAqr7cs5hSRrkCTqUrDKmOAyILVNTUeY5ZODiFgDiWic8iDhdgr/1dHTVcuX8+Z7mS5jv9QnCI3Xd5NOAxzBJ4QpWfzpO7IwJx00Sz64qqzOyTqrxktIOzKvdPOsx8nQGNGbe47LxSUOKm+SfCVTVn1xcbinZg4oRNhjWg=="));
        formParams.add(new BasicNameValuePair("__VIEWSTATEGENERATOR", "F9829FDA"));
        formParams.add(new BasicNameValuePair("__VIEWSTATEENCRYPTED", null));
        formParams.add(new BasicNameValuePair("__ASYNCPOST", "ture"));

        // 设置form-data到请求
        UrlEncodedFormEntity entity = new UrlEncodedFormEntity(formParams, "UTF-8");
        post.setEntity(entity);

        // 设置请求头部的信息
        post.setHeader("Content-type", "application/json");
        Map<String, String> map1 = getCookie();
        String cookie = "ASP.NET_SessionId="+map1.get("ASP.NET_SessionId");
        post.setHeader("Cookie", cookie);
        // 执行登录操作
        CloseableHttpResponse execute = (CloseableHttpResponse) client.execute(post);
        // 获取响应的内容
        String responseBody = EntityUtils.toString(execute.getEntity());
        System.out.println(responseBody);


        return null;
    }
    public static String  getVIEWSTATE() throws UnsupportedEncodingException {
        // 创建HttpClient实例
        CloseableHttpClient httpClient = HttpClients.createDefault();
        String url = "http://10.154.136.200/oa/NOTICE/noticeManageList.aspx?pstrid=BTZGG";
        // 创建HttpPost实例，设置URL
        HttpPost httpPost = new HttpPost(url);

        httpPost.setHeader("Cookie", "MyCookie=PageHeight=455; ASP.NET_SessionId=adarftwyc24hkn0xza0oeroc");
        httpPost.setHeader("Connection", "keep-alive");

        try {
            // 执行请求
            HttpResponse response = httpClient.execute(httpPost);
            // 获取响应的内容
            String responseBody = EntityUtils.toString(response.getEntity());
            // 打印响应内容
            System.out.println("获取未读："+responseBody);
            String regex="<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=.*?\" />";
            Pattern pattern = Pattern.compile(regex);
            Matcher m = pattern.matcher(responseBody);
            List<String> list = new ArrayList<>();
            while (m.find()){
                list.add(m.group());
            }
            String text = list.get(0).split("<input type=\"hidden\" name=\"__VIEWSTATE\" id=\"__VIEWSTATE\" value=\"")[1].split("\" />")[0];
            return text;
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                httpClient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }

    @Log(title = "未读数据发送ekp", businessType = BusinessType.OTHER)
    @GetMapping("/sendEkp")
    public AjaxResult sendEkp()throws Exception{
        //查询未发送的数据
        SysSdtService sysSdtServiceBean= SpringUtils.getBean(SysSdtService.class);
        SysSdt sysSdt = new SysSdt();
        sysSdt.setIsSend("0");
        List<SysSdt> sysSdts = sysSdtServiceBean.selectList(sysSdt);
        log.info("查询未发送的数据："+sysSdts.size());
        sysSdts.forEach(sysSdt1 -> {
            try {
                boolean extracted = extracted(sysSdt1);
                if (extracted){
                    sysSdt.setId(sysSdt1.getId());
                    sysSdt.setIsSend("1");
                    sysSdtServiceBean.update(sysSdt);
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        });
        return AjaxResult.success();
    }

    private static boolean extracted(SysSdt sysSdt) {
//        HttpRequest request = HttpRequest.post("http://localhost:8080/api/km-imissive/kmSaveImissiveRestService/addNews");
        HttpRequest request = HttpRequest.post("https://wfgxgz.com/api/km-imissive/kmSaveImissiveRestService/addNews");

        HashMap<String, Object> bodyMap = new HashMap<>();
        request.form("docSubject", sysSdt.getLblTitle());
        request.form("fdTemplateId", "1941679e0412f833f821c9a4a7086184");
        request.form("docContent", sysSdt.getEditor());
        request.form("docCreator", "{Id:19471f9352013f1d12b7f3e45f68fd7c}");
        request.form("fdDepartmentId", "19471f79bdc311b7e9cd9b945188a907");
        request.form("fdAuthor", "刘金波");

        request.form("fdDocNum", generateDailySequence());
//        request.form("fdHandleResult", "办理结果");
//        request.form("fdInstructcontent", "批示内容");
        request.form("fdSendtoUnit", "193693c07843972d409de0a48ddbd906");

        String regex=".*?\\..*?;";
        Pattern pattern = Pattern.compile(regex);
        Matcher m = pattern.matcher(sysSdt.getFilePath());
        List<String> list = new ArrayList<>();
        while (m.find()){
            list.add(m.group());
        }
        list = list.stream()
                .map(s -> s.substring(0, s.length() - 1))
                .collect(Collectors.toList());
//        List<String> list = Arrays.asList(sysSdt.getFilePath().split(";"));
        for (int i = 0; i < list.size(); i++) {
            String resource = list.get(i);
            // 本地资源路径
            String localPath = RuoYiConfig.getProfile();
            // 数据库资源地址
            String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
            // 下载名称
            String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
            // 创建文件
            File file = new File(downloadPath);
            request.form("allAttachmentForms["+i+"].fdAttachment", file);
            request.form("allAttachmentForms["+i+"].fdKey", "mainonline");
            request.form("allAttachmentForms["+i+"].fdFileName", downloadName);
        }

        HashMap<String, String> headerMap = new HashMap<>();
        headerMap.put("Content-Type", "application/json");
        // 请求
        cn.hutool.http.HttpResponse response = request.basicAuth("ekp", "ekp@2025")
                .addHeaders(headerMap).timeout(20000).execute();
        // 响应
        String body = response.body();
        System.out.println("返回的数据："+body);
        // 添加响应结果判断
        if (response.getStatus() == 200 && StringUtils.isNotBlank(body)) {
            log.info("推送成功：{}", sysSdt.getLblTitle());
            return true;
        } else {
            log.error("推送失败 | 状态码：{} | 响应内容：{}", response.getStatus(), body);
            return false;
        }

    }

    private static final AtomicLong monthlyCounter = new AtomicLong(0);
    private static String currentMonth = DateUtil.format(new Date(), "yyyy-MM");

    private synchronized static String generateDailySequence() {
        // 获取当前年月日（格式：yyyyMMdd）
        String currentDate = DateUtil.format(new Date(), "yyyyMMdd");
        // 获取当前月份（格式：yyyy-MM）
        String newMonth = DateUtil.format(new Date(), "yyyy-MM");

        // 每月重置计数器
        if (!newMonth.equals(currentMonth)) {
            currentMonth = newMonth;
            monthlyCounter.set(0);
        }

        // 格式：年月日 + 每月自增序号（4位）
        return currentDate + String.format("%04d", monthlyCounter.incrementAndGet());
    }

}




